<?php
namespace Home\Model;
use Think\Model\RelationModel;

class StudentModel extends  RelationModel{

    protected $_link = array(
        "college"=>array(
            "mapping_type"=>2,
            "class_name"=>"college",
            "mapping_name"=>"college",
            "foreign_key"=>"col_id",
            "as_fields"=>"col_name"
        ),
    );

    protected $_validate = array(
        //查询(导入)学生的时候用
        array("stu_number","require","学生的学号必须填写!",1,"regex",4),
        //注册时候验证
        array("stu_number","require","学生的学号必须填写!",1,"regex",1),
        array("stu_password_hash","require","学生的密码必须填写!",1,"regex",1),
        array("stu_name","require","学生的姓名必须填写!",1,"regex",3),
        array("stu_email","email","学生的邮箱格式有误!",1,"regex",1),
        array("col_id","number","学校id必须是正整数!",1,"regex",1),
        array("sex",array("男","女"),"性别只有男和女选择!",1,"in",2),
    );
    protected $_auto = array(
        array("sex","男",1),
    );

}